package com.dao.qsl;

import com.util.qsl.Dbutil;
import org.springframework.stereotype.Repository;

import javax.servlet.http.HttpServletRequest;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Repository
public class Emp {
      public  List<String> getename(HttpServletRequest request){
	  Dbutil d=new Dbutil();
	  Connection c=null;

	  List<String> list=new ArrayList<>();
	  try {
	      c=d.getConnection();
	      String sql="SELECT  ename FROM  emp";

	        PreparedStatement pr=c.prepareStatement(sql);

	        ResultSet rs=pr.executeQuery();


	        Map<String,Object> user = (Map<String,Object>)request.getSession().getAttribute("user");
	        String  ename = (String) user.get("ename");

	        while (rs.next()){
		    if(ename.equals(rs.getString("ename"))){

		    }else {
			list.add(rs.getString("ename"));
		    }

	        }
	  }catch (Exception e){
	        e.printStackTrace();
	  }
	  return list;
      }
}
